<template>
  <div class="bg-white dy-form">
    <div @click="print">打印</div>
    <div class="flex1">
      <f-dy-editor style="height: 100%" v-model:value="options"></f-dy-editor>
    </div>
    <div class="w40"></div>
    <div class="flex1">
      <f-dy-form
        v-if="formItems"
        :formItems="formItems"
        ref="form"
        style="overflow-y: auto"
        :config="options"></f-dy-form>
    </div>
  </div>
</template>
<script lang="ts" setup>
import { http } from 'fok-ui';
import { ref } from 'vue';
const form = ref();
const print = () => {
  form.value.print();
};
const columns = ref([
  {
    label: 'select',
    type: 'super-set',
    field: 'select',
    required: true,
    props: {
      type: 'select',
      query: () => [
        { label: 'item 1', value: 1 },
        { label: 'item 2', value: 2 }
      ]
    }
  }
]);
const options = ref({
  type: 'form',
  mainTitle: '阜康医院',
  title: '康复治疗记录',
  anchor: false,
  config: {
    layout: 'vertical',
    colSpan: 12,
    labelWidth: 1300,
    columns: [
      {
        label: '基础信息',
        span: 24,
        columns: [
          { label: '科室名称', field: 'HDSD00.02.366' },
          { label: '评定时间', field: 'HDSD00.02.424' },
          { label: '疼痛评估处理措施', field: 'new001924' },
          { label: '长海痛尺评分', field: 'new001013' },
          { label: '测试结果', field: 'tttA2' },
          { label: '入院日期', field: 'HDSD00.02.461' }
        ]
      },
      {
        label: '分布信息',
        span: 24,
        columns: [
          { label: '审阅人签名', field: 'new001925' },
          { label: '入院诊断', field: 'HDSD00.02.464' },
          { label: '病床号', field: 'HDSD00.02.028' },
          { label: '评估医师', field: 'HDSD00.02.799' },
          { label: '测试', field: 'tttA1' }
        ]
      },
      {
        label: '嘻嘻嘻嘻嘻i',
        span: 24,
        columns: [
          { label: '评定时间', field: 'HDSD00.02.424' },
          { label: '疼痛评估处理措施', field: 'new001924' },
          { label: '长海痛尺评分', field: 'new001013' },
          { label: '测试结果', field: 'tttA2' },
          { label: '测试', field: 'tttA1' },
          { label: '病床号', field: 'HDSD00.02.028' },
          { label: '住院号', field: 'HDSD00.02.805' }
        ]
      },
      { label: '评估医师', field: 'HDSD00.02.799' },
      { label: '测试', field: 'tttA1' },
      { label: '评定时间', field: 'HDSD00.02.424' },
      { label: '疼痛评估处理措施', field: 'new001924' },
      { label: '长海痛尺评分', field: 'new001013' },
      { label: '测试结果', field: 'tttA2' },
      { label: '入院日期', field: 'HDSD00.02.461' },
      { label: '审阅人签名', field: 'new001925' },
      { label: '入院诊断', field: 'HDSD00.02.464' },
      { label: '入院诊断', field: 'HDSD00.02.464' },
      { label: '入院诊断', field: 'HDSD00.02.464' },
      { label: '病床号', field: 'HDSD00.02.028' },
      { label: '住院号', field: 'HDSD00.02.805' },
      { label: '评估医师', field: 'HDSD00.02.799' },
      { label: '测试', field: 'tttA1' },
      { label: '评定时间', field: 'HDSD00.02.424' },
      { label: '疼痛评估处理措施', field: 'new001924' },
      { label: '长海痛尺评分', field: 'new001013' },
      { label: '测试结果', field: 'tttA2' },
      { label: '入院日期', field: 'HDSD00.02.461' },
      { label: '审阅人签名', field: 'new001925' },
      { label: '病床号', field: 'HDSD00.02.028' },
      { label: '住院号', field: 'HDSD00.02.805' },
      { label: '评估医师', field: 'HDSD00.02.799' },
      { label: '测试', field: 'tttA1' },
      { label: '评定时间', field: 'HDSD00.02.424' },
      { label: '疼痛评估处理措施', field: 'new001924' },
      { label: '长海痛尺评分', field: 'new001013' },
      { label: '测试结果', field: 'tttA2' },
      { label: '入院日期', field: 'HDSD00.02.461' },
      { label: '审阅人签名', field: 'new001925' },
      { label: '入院诊断', field: 'HDSD00.02.464' },
      { label: '入院诊断', field: 'HDSD00.02.464' },
      { label: '病床号', field: 'HDSD00.02.028' },
      { label: '病床号', field: 'HDSD00.02.028' },
      { label: '住院号', field: 'HDSD00.02.805' },
      { label: '住院号', field: 'HDSD00.02.805' },
      { label: '评估医师', field: 'HDSD00.02.799' },
      { label: '评估医师', field: 'HDSD00.02.799' },
      { label: '测试', field: 'tttA1' },
      { label: '测试', field: 'tttA1' },

      { label: '评定时间', field: 'HDSD00.02.424' },
      { label: '评定时间', field: 'HDSD00.02.424' },
      { label: '疼痛评估处理措施', field: 'new001924' },
      { label: '疼痛评估处理措施', field: 'new001924' },
      { label: '长海痛尺评分', field: 'new001013' },
      { label: '长海痛尺评分', field: 'new001013' },
      { label: '测试结果', field: 'tttA2' },
      { label: '测试结果', field: 'tttA2' },
      { label: '入院日期', field: 'HDSD00.02.461' },
      { label: '入院日期', field: 'HDSD00.02.461' },
      { label: '审阅人签名', field: 'new001925' },
      { label: '审阅人签名', field: 'new001925' },
      { label: '入院诊断', field: 'HDSD00.02.464' },
      { label: '入院诊断', field: 'HDSD00.02.464' },
      { label: '病床号', field: 'HDSD00.02.028' },
      { label: '病床号', field: 'HDSD00.02.028' },
      { label: '住院号', field: 'HDSD00.02.805' },
      { label: '住院号', field: 'HDSD00.02.805' },
      { label: '评估医师', field: 'HDSD00.02.799' },
      { label: '评估医师', field: 'HDSD00.02.799' },
      { label: '测试', field: 'tttA1' },
      { label: '测试', field: 'tttA1' },

      { label: '评定时间', field: 'HDSD00.02.424' },
      { label: '评定时间', field: 'HDSD00.02.424' },
      { label: '疼痛评估处理措施', field: 'new001924' },
      { label: '疼痛评估处理措施', field: 'new001924' },
      { label: '长海痛尺评分', field: 'new001013' },
      { label: '长海痛尺评分', field: 'new001013' },
      { label: '测试结果', field: 'tttA2' },
      { label: '测试结果', field: 'tttA2' },
      { label: '入院日期', field: 'HDSD00.02.461' },
      { label: '入院日期', field: 'HDSD00.02.461' },
      { label: '审阅人签名', field: 'new001925' },
      { label: '审阅人签名', field: 'new001925' },
      { label: '入院诊断', field: 'HDSD00.02.464' },
      { label: '病床号', field: 'HDSD00.02.028' },
      { label: '住院号', field: 'HDSD00.02.805' },
      { label: '评估医师', field: 'HDSD00.02.799' },
      { label: '测试', field: 'tttA1' },
      { label: '测试', field: 'tttA1' },
      { label: '评定时间', field: 'HDSD00.02.424' },
      { label: '疼痛评估处理措施', field: 'new001924' },
      { label: '长海痛尺评分', field: 'new001013' },
      { label: '测试结果', field: 'tttA2' },
      { label: '入院日期', field: 'HDSD00.02.461' },
      { label: '审阅人签名', field: 'new001925' },
      { label: '入院诊断', field: 'HDSD00.02.464' },
      { label: '病床号', field: 'HDSD00.02.028' },
      { label: '住院号', field: 'HDSD00.02.805' },
      { label: '评估医师', field: 'HDSD00.02.799' },
      { label: '测试', field: 'tttA1' },
      { label: '评定时间', field: 'HDSD00.02.424' },
      { label: '疼痛评估处理措施', field: 'new001924' },
      { label: '长海痛尺评分', field: 'new001013' },
      { label: '测试结果', field: 'tttA2' },
      { label: '入院日期', field: 'HDSD00.02.461' },
      { label: '审阅人签名', field: 'new001925' },
      { label: '入院诊断', field: 'HDSD00.02.464' },
      { label: '病床号', field: 'HDSD00.02.028' },
      { label: '评估医师', field: 'HDSD00.02.799' },
      { label: '测试', field: 'tttA1' },
      { label: '评定时间', field: 'HDSD00.02.424' },
      { label: '疼痛评估处理措施', field: 'new001924' },
      { label: '长海痛尺评分', field: 'new001013' },
      { label: '测试结果', field: 'tttA2' },
      { label: '入院日期', field: 'HDSD00.02.461' },
      { label: '审阅人签名', field: 'new001925' },
      { label: '入院诊断', field: 'HDSD00.02.464' },
      { label: '病床号', field: 'HDSD00.02.028' },
      { label: '评估医师', field: 'HDSD00.02.799' },
      { label: '入院日期', field: 'HDSD00.02.461' },
      { label: '审阅人签名', field: 'new001925' }
    ]
  }
});
const formItems = ref();
const queryTree = () => {
  http
    .post('/clinical/fromItem/queryTree', { t: 1740375718459, id: '1910588652240363520' })
    .then((res) => {
      const cached = {};
      const each = (data) => {
        data.forEach((item) => {
          if (item.internalNo) {
            cached[item.internalNo.replace(/\./g, '__')] = item;
          }
          if (item.internalNo === 'HDSD00.02.366') {
            item.controlType = { code: '2' };
          }
          if (item.children) {
            each(item.children);
          }
        });
      };

      each(res.data);
      formItems.value = res.data;
    });
};
queryTree();
const submit = async () => {
  const d = await form.value.submit();
  console.log(d);
};
</script>

<style lang="scss">
.dy-form {
  display: flex;
  height: 100vh;
  padding: 15px;
}

.flex1 {
  flex: 1;
  width: 0;
}
</style>
